package cn.com;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import news.LeiBie;
import news.NewTi;

import dao.MysqlLeiBie;
import dao.MysqlNew;

public class leibieshowServlet extends HttpServlet {

	/**
	 * Constructor of the object.
	 */
	public leibieshowServlet() {
		super();
	}

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		this.doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");

		MysqlNew mn = new MysqlNew();
		List<NewTi> list1 = mn.GMshow(1, 5);
		request.setAttribute("list1", list1);
		List<NewTi> list2 = mn.GMshow(2, 5);
		request.setAttribute("list2", list2);
		List<NewTi> list3 = mn.GMshow(5, 5);
		request.setAttribute("list3", list3);
		MysqlLeiBie my = new MysqlLeiBie();
		ArrayList<LeiBie> list4 = my.showBei();
		request.setAttribute("list4", list4);

		String tid = request.getParameter("tid");
		// tname = new String(tname.getBytes("ISO-8859-1"), "utf-8");
		Integer intid = Integer.parseInt(tid);
		int jiid = intid;
		MysqlLeiBie my5 = new MysqlLeiBie();
		ArrayList<NewTi> listlei = my5.fenlei(jiid);
		request.setAttribute("listlei", listlei);
		request.getRequestDispatcher("leibieshow.jsp").forward(request,
				response);
	}

	/**
	 * Initialization of the servlet. <br>
	 * 
	 * @throws ServletException
	 *             if an error occurs
	 */
	public void init() throws ServletException {
		// Put your code here
	}

}
